use crate::sources::cgtn::categories::categories as cgtn_categories;
use crate::sources::chinadaily::categories::categories as chinadaily_categories;
use crate::utils::{Array, SourceOrCategory};

#[tauri::command]
pub fn get_sources() -> Array<SourceOrCategory<'static>> {
    Array {
        items: vec![
            SourceOrCategory {
                name: "历史记录",
                id: "history",
                default: false,
            },
            SourceOrCategory {
                name: "CGTN",
                id: "cgtn",
                default: true,
            },
            SourceOrCategory {
                name: "China Daily",
                id: "chinadaily",
                default: false,
            },
        ],
    }
}

#[tauri::command]
pub fn get_categories(source: &str) -> Array<SourceOrCategory> {
    match source {
        "history" => Array {
            items: vec![SourceOrCategory {
                name: "历史记录",
                id: "history",
                default: true,
            }],
        },
        "cgtn" => Array {
            items: cgtn_categories(),
        },
        "chinadaily" => Array {
            items: chinadaily_categories(),
        },
        _ => unimplemented!(),
    }
}
